package com.jyu.apts.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jyu.apts.dao.OrganizationRoleRepository;
import com.jyu.apts.entity.Organization;
import com.jyu.apts.entity.OrganizationRole;
import com.jyu.apts.service.OrganizationRoleService;

@Service
public class OrganizationRoleServiceImpl implements OrganizationRoleService {

	@Autowired
	OrganizationRoleRepository organizationRoleDao;
	
	@Override
	public OrganizationRole getOne(long id) {
		return organizationRoleDao.findById(id).get();
	}

	@Override
	public List<OrganizationRole> findAll() {
		return organizationRoleDao.findAll();
	}

	@Override
	public void save(OrganizationRole organizationRole) {
		organizationRoleDao.saveAndFlush(organizationRole);
	}

	@Override
	public void save(List<OrganizationRole> organizationRoles) {
		organizationRoleDao.saveAll(organizationRoles);
		organizationRoleDao.flush();
	}

	@Override
	public void delete(OrganizationRole organizationRole) {
		organizationRoleDao.delete(organizationRole);
	}

	@Override
	public void delete(List<OrganizationRole> organizationRoles) {
		organizationRoleDao.deleteAll(organizationRoles);
	}

	@Override
	public List<OrganizationRole> findAllById(List<Long> ids) {
		return organizationRoleDao.findAllById(ids);
	}

	@Override
	public OrganizationRole findByNameAndOrganization(String name,Organization organization) {
		return organizationRoleDao.findByNameAndOrganization(name,organization);
	}

}
